<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateRepairOrderAffectedTaskTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('repair_order_affected_task', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '返修受影响任务']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('task_repair_order_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '返修单id'])
            ->addColumn('task_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '任务id'])
            ->addColumn('version_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '版本id'])
            ->addColumn('repair_status', 'enum', ['values' => 'yes,no', 'default' => 'no', 'null' => false, 'comment' => '返修是否完成'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间'])
            ->addIndex(['task_id'], ['type' => 'normal', 'name' => 'idx_task_id'])
            ->save();
    }

    public function down()
    {
        $this->table('repair_order_affected_task')->drop()->save();
    }
}
